package org.example.mybatis.mapper;

import org.apache.catalina.User;
import org.example.mybatis.model.UserInfo;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

import static org.junit.jupiter.api.Assertions.*;

@SpringBootTest
//不添加这个注释，会注入失败
class IUserInfoMapperTest {

    @Autowired
    private IUserInfoMapper iUserInfoMapper;
    @Test
    void getUserInfoAll() {
       List<UserInfo> infos =  iUserInfoMapper.getUserInfoAll();
        System.out.println(infos);
    }

    @Test
    void getUserInfo1() {
        List<UserInfo> infos = iUserInfoMapper.getUserInfo1(19);
        System.out.println(infos);
    }

    @Test
    void getUserInfo2() {
        List<UserInfo> infos = iUserInfoMapper.getUserInfo2(2,19);
        System.out.println(infos);
    }

    @Test
    void getUserInfo3() {
        System.out.println(iUserInfoMapper.getUserInfo3(4));
    }

    @Test
    void getUserInfo4() {
        System.out.println(iUserInfoMapper.getUserInfo4(4));
    }

    @Test
    void insertUserInfo1() {
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("小美");
        userInfo.setPassword("123456");
        userInfo.setAge(18);
        userInfo.setGender(1);
        Integer n = iUserInfoMapper.insertUserInfo1(userInfo);
        System.out.println("影响行数:"+n);
    }

    @Test
    void insertUserInfo2() {
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("小美");
        userInfo.setPassword("123456");
        userInfo.setAge(18);
        userInfo.setGender(1);
        Integer n = iUserInfoMapper.insertUserInfo2(userInfo);
        System.out.println("影响行数:"+n+", id:"+ userInfo.getId());
    }

    @Test
    void insertUserInfo3() {
        UserInfo userInfo = new UserInfo();
        userInfo.setUsername("小美");
        userInfo.setPassword("123456");
        userInfo.setAge(18);
        userInfo.setGender(1);
        Integer n = iUserInfoMapper.insertUserInfo3(userInfo);
        System.out.println("影响行数:"+n);
    }

    @Test
    void deleteUserInfo1() {
        UserInfo userInfo = new UserInfo();
        userInfo.setId(5);
        Integer n = iUserInfoMapper.deleteUserInfo1(userInfo);
        System.out.println("影响行数:"+n);
    }

    @Test
    void upsetUserInfo1() {
        UserInfo userInfo = new UserInfo();
        userInfo.setPassword("16666");
        userInfo.setGender(1);
        userInfo.setId(6);
        Integer n = iUserInfoMapper.upsetUserInfo1(userInfo);
        System.out.println("影响行数："+n);
    }

    @Test
    void getUserInfoAll1() {
        System.out.println(iUserInfoMapper.getUserInfoAll1());
    }

    @Test
    void getUserInfoAll2() {
        System.out.println(iUserInfoMapper.getUserInfoAll2());
    }

    @Test
    void getUserInfoAll3() {
        System.out.println(iUserInfoMapper.getUserInfoAll3());
    }
}